<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>企业员工工资管理-工资详情</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="static/css/font.css">
<link rel="stylesheet" href="static/css/xadmin.css">
<script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="static/lib/layui/layui.js"></script>
<script type="text/javascript" src="static/js/xadmin.js"></script>
</head>

<body class="layui-anim layui-anim-up">

	<div class="x-nav">
		<span class="layui-breadcrumb"> <a>首页</a> <a>考评管理</a> <a> <cite>评分管理</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"> <i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body" id="container">
		<div class="demoTable">
			员工号：
			<div class="layui-inline">
				<input type="number" id="e_id" name="e_id" required
					lay-verify="number" autocomplete="off" class="layui-input" value="" />
			</div>
			<button class="layui-btn" data-type="reload">查&nbsp;&nbsp;询</button>
		</div>
		<div style="text-align: center">
			<table id="demo" class="layui-table" lay-filter="demo"></table>
		</div>
		<div class="layui-inline">
			<a class="layui-btn layui-btn-danger batchUnlock"><i
				class="layui-icon layui-icon-key"></i>提交</a>
		</div>
	</div>
</body>
<script>
    layui.use(['laydate','table'], function(){
            var laydate = layui.laydate
            ,table = layui.table;
        
          //第一个实例
         table.render({
             elem: '#demo'
            ,height: 'full'
            ,url: 'employeeGrand.do'
            ,page: false
            ,initSort: {field: 'sTime', type: 'desc'}
            ,id:'demo'
            ,cols: [[ //表头
               {field:'eAccount', rowspan:2, title: '工号', width:120, align: 'center',fixed: 'left'}
              ,{field: 'eName', rowspan:2, title: '姓名', width:80, align: 'center',fixed: 'left'}
              ,{minWidth:100, title:'德', align:'center',colspan:3}
              ,{minWidth:100, title:'能', align:'center',colspan:3}
              ,{minWidth:100, title:'勤', align:'center',colspan:3}
              ,{minWidth:100, title:'绩', align:'center',colspan:3}
              ,{minWidth:100, title:'廉', align:'center',colspan:2}
             ],
                [
                	 {field:'aTargetscore1', title:'道德品质' ,minWidth:100, align: 'center',edit:'number'} 
                	,{field:'aTargetscore2', title:'个人品德修养' ,minWidth:100, align: 'center',edit:'number'}
                    ,{field:'aTargetscore3', title:'政治品质' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore4', title:'言行表现' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore5', title:'表达沟通能力' , minWidth:120,align: 'center',edit:'number'}
                    ,{field:'aTargetscore6', title:'岗位适应能力' , minWidth:120,align: 'center',edit:'number'}
                    ,{field:'aTargetscore7', title:'日常出勤' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore8', title:'勤奋程度' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore9', title:'责任心' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore10', title:'工作负荷' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore11', title:'工作质量' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore12', title:'工作时效' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore13', title:'廉洁自律' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'aTargetscore14', title:'勤俭节约' , minWidth:100,align: 'center',edit:'number'},
                    
                ]
            ]
         });

        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');
                //执行重载
                console.log(demoReload);
                table.reload('demo', {
                    where: {
                        e_id: $("#e_id").val()
                    }
                });
            }
        };
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            console.log(type);
            active[type] ? active[type].call(this) : '';
        });
        
        //批量提交  使用封装后的ajax
        $(".batchUnlock").click(function (){
            const list = table.cache['demo'];
            var len = list.length;
            for(var i=0; i<len; i++){
            	delete list[i].LAY_TABLE_INDEX;
        	}
            console.log(list);
            console.log("list="+JSON.stringify(list));
            $.ajax({
                type: 'post',
                url: 'updateGrand.do',
                data: "list="+JSON.stringify(list),
                dataType: 'json',
                success: function (result) {
                	if(result.code==0){
                		layer.msg(result.msg);
 
                	}else{
                		layer.msg(result.msg);
                	}
                }
            });
           
        });
        
        layui.use(['table','form'], function () {
            var table = layui.table;
            var form = layui.form;
            //添加评审栏下拉框点击事件（这里是添加点击事件）
            table.on('edit(demo)', function(obj){
                var field = obj.field
                var value = obj.value //得到修改后的值
                var data = obj.data //得到所在行所有键值
                var regPos = /^\d+(\.\d+)?$/; //非负浮点数
                var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
                if((!regPos.test(value)) && !regNeg.test(value) && !value.match("[1-9]+")){
                    layer.msg("请输入1-9纯数字")
                    return;
                }
            });
        });
        
    });
    
    
    
    
</script>
</html>